var e = require;
var t = module;
var o = exports;
var Adv_skd=require("./Adv_skd");
Object.defineProperty(o, "__esModule", {value: !0});
var n = e("BaseModuleUI"),
    a = e("GlobalParams"),
    i = e("AssetsManager"),
    r = e("AudioManager"),
    s = e("UIManager"),
    l = e("sdkConfig"),
    c = e("AD"),
    d = e("Toast"),
    h = cc._decorator,
    _ = h.ccclass,
    u = h.property,
    p = (function (e) {
        function t() {
            var t = (null !== e && e.apply(this, arguments)) || this;
            return (
                (t.hero_ske = null),
                (t.win_or_lose = null),
                (t.level_icon = null),
                (t.level_exp_star = null),
                (t.coin_num = null),
                (t.zs_num = null),
                (t.share_view_node = null),
                (t.add_coin = 0),
                (t.add_zs = 0),
                (t.uiManager = null),
                t
            );
        }
        return (
            __extends(t, e),

            (t.prototype.onDisable = function () {
                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
            }),

            (t.prototype.initView = function () {

                Adv_skd.default.instance.hideBannerAd();
                Adv_skd.default.instance.hideGridAdLeft();
                Adv_skd.default.instance.hideGridAdRight();
                Adv_skd.default.instance.hideGridAdTop();
                Adv_skd.default.instance.hideGridAdLeftOne();
                Adv_skd.default.instance.hideGridAdRightOne();
                Adv_skd.default.instance.hideGridAdButtom();
                Adv_skd.default.instance.showGridAdTop();
                Adv_skd.default.instance.showGridAdLeft();
                Adv_skd.default.instance.showGridAdRight();
                Adv_skd.default.instance.showInterstitialAd();
                Adv_skd.default.instance.showBannerAd();

                (this.share_view_node.active = l.default.platform == l.EPlatform.TikTok),
                    (this.uiManager = cc.find("UIManager").getComponent(s.default)),
                    this.uiManager.showCoinAndZs(!0),
                    (a.GlobalParams.PlayGuideMode = !1),
                    c.default.getInstance().showInter(),
                    this.showViewInfo();
            }),
            (t.prototype.showViewInfo = function () {
                var e = this;
                (this.win_or_lose.children[0].active = a.GlobalParams.GamePlayerWin),
                    (this.win_or_lose.children[1].active = !a.GlobalParams.GamePlayerWin);
                var t = a.GlobalParams.PlayerInfo.value;
                this.level_icon.spriteFrame = i.default.getInstance().getPlayerLevelExp(t.level);
                var o = a.GlobalParams.MatchGamePlayer[a.GlobalParams.MatchMyIndex].kill_info;
                this.uiManager.getRoleSkele(
                    a.GlobalParams.MatchGamePlayer[a.GlobalParams.MatchMyIndex].role_id,
                    function (t) {
                        (e.hero_ske.skeletonData = t), e.hero_ske.setAnimation(0, "battle_idle", !0);
                    }
                );
                for (var n = 0; n < 4; n++) this.level_exp_star.children[n].children[0].active = n <= t.exp;
                a.GlobalParams.GamePlayerWin &&
                    (t.exp++,
                    this.scheduleOnce(function () {
                        if (t.exp < 4) {
                            var o = e.level_exp_star.children[t.exp].children[0];
                            (o.active = !0), (o.scale = 2), cc.tween(o).to(0.5, {scale: 1}).start();
                        } else if ((t.level++, t.level < 29)) {
                            t.exp = 0;
                            for (
                                var n = function (o) {
                                        e.scheduleOnce(function () {
                                            var n = e.level_exp_star.children[o].children[0];
                                            cc.tween(n)
                                                .to(0.3, {scale: 0})
                                                .call(function () {
                                                    0 == o &&
                                                        (e.level_icon.spriteFrame = i.default
                                                            .getInstance()
                                                            .getPlayerLevelExp(t.level));
                                                })
                                                .start();
                                        }, 0.3 * (3 - o));
                                    },
                                    a = 3;
                                a > -1;
                                a--
                            )
                                n(a);
                        }
                    }, 1),
                    (a.GlobalParams.PlayerInfo.value = t),
                    this.uiManager.playerTaskOverInfo(3, 1),
                    this.uiManager.playerTaskOverInfo(4, 1),
                    this.uiManager.playerTaskOverInfo(8, 1)),
                    (this.add_coin = a.GlobalParams.GamePlayerWin ? 100 : 20),
                    (this.add_coin += 3 * o[0] - 2 * o[1] + 0.5 * o[2]),
                    (this.add_coin = Math.ceil(this.add_coin)),
                    (this.add_zs = a.GlobalParams.GamePlayerWin ? 10 : 2),
                    (this.coin_num.string = "+" + this.add_coin),
                    (this.zs_num.string = "+" + this.add_zs);
            }),
            (t.prototype.OnClick = function (t) {
                var o = this;
                e.prototype.OnClick.call(this, t);
                var n = t.node.name;
                switch (n) {
                    case "get_btn":
                    case "three_btn":
                        var s = function () {
                            var e = o.add_coin * ("get_btn" == n ? 1 : 3),
                                t = o.add_zs * ("get_btn" == n ? 1 : 3);
                            o.uiManager.addCoinAni(e, 0),
                                o.uiManager.addCoinAni(t, 1),
                                o.uiManager.showCoinAndZs(!1),
                                cc
                                    .find("Canvas")
                                    .addChild(
                                        cc.instantiate(i.default.getInstance().getFightPrefab("GameOverMenuViewUI"))
                                    ),
                                o.node.destroy();
                        };
                        "three_btn" == n
                            ? c.default.getInstance().showVideo(function (e) {
                                  r.default.playGameBGM(), e == c.ResultEnum.Success && s();
                              })
                            : s();
                        break;
                    case "share_btn":
                        var l = a.GlobalParams.ShareVidoeInfo.value;
                        c.default.getInstance().ShareVideo(
                            "今天上王者",
                            "xdj1wsbqjo3pm5h9kf",
                            function () {
                                if (l != new Date().toLocaleDateString()) {
                                    var e = a.GlobalParams.playerSkinInfo.value;
                                    e.have.taste_card++,
                                        (a.GlobalParams.playerSkinInfo.value = e),
                                        (l = new Date().toLocaleDateString()),
                                        (a.GlobalParams.ShareVidoeInfo.value = l),
                                        d.default.showNewToast("分享成功，获得英雄体验卡*1"),
                                        (o.share_view_node.active = !1);
                                }
                            },
                            function () {
                                d.default.showNewToast("分享失败");
                            }
                        );
                }
            }),
            __decorate([u(sp.Skeleton)], t.prototype, "hero_ske", void 0),
            __decorate([u(cc.Node)], t.prototype, "win_or_lose", void 0),
            __decorate([u(cc.Sprite)], t.prototype, "level_icon", void 0),
            __decorate([u(cc.Node)], t.prototype, "level_exp_star", void 0),
            __decorate([u(cc.Label)], t.prototype, "coin_num", void 0),
            __decorate([u(cc.Label)], t.prototype, "zs_num", void 0),
            __decorate([u(cc.Node)], t.prototype, "share_view_node", void 0),
            __decorate([_], t)
        );
    })(n.default);
o.default = p;
